import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class Loading {
  static BuildContext ctx;
  static BuildContext ctxs;

  static showLoading(bool loading) {
    if (loading) {
      showDialog(
          context: ctx,
          builder: (ctx) {
            Loading.ctxs = ctx;
            return Container(
              child: Lottie.asset('assets/lottie/loading.json',
                  width: 100, height: 100),
            );
          });
    } else {
      Navigator.pop(ctxs);
    }
  }

  static showToast(String msg) {
    if (msg.isEmpty) {
      return;
    }
    Fluttertoast.showToast(
        msg: msg,
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: Colors.black26,
        textColor: Colors.white,
        fontSize: 16.sp);
  }
}
